package com.jeffry.redial;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;

import java.util.ArrayList;

public class Utils {

    public static interface Constants {
        public static final String NUMBERS_LIST = "numbers_list";

        public static final String EXTRA_NUMBERS_LIST ="extra_numbers_list";

        public static int REQUEST_NUMBERS_LIST = 10;
    }

    public static ArrayList<String> getNumbersList(Context context) {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        ArrayList<String> list = new ArrayList<String>();
        String numberStr = prefs.getString(Constants.NUMBERS_LIST, "");
        String[] numbers = TextUtils.isEmpty(numberStr) ? null : numberStr.split(";");

        if (numbers != null && numbers.length > 0) {
            for (String s : numbers)
                list.add(s);
        }

        return list;
    }
}
